package string;

public class StringBuilderDemo {
    public static void main(String[] args) {
        String str ="好好学习ABC";
        StringBuilder builder=new StringBuilder(str);

        //增加
        builder.append(",为了娶媳妇");
        System.out.println(builder);

        //替换
        builder.replace(8,17,"就是为了饿不死");
        System.out.println(builder);

        //删除
        builder.delete(0,8);
        System.out.println(builder);

        //插入
        builder.insert(0,"活着");
        System.out.println(builder);





//        StringBuilder builder1=new StringBuilder();//空字符串
//        StringBuilder builder2=new StringBuilder("abc");//abc串
//
//        String str ="abc";
//        StringBuilder builder3=new StringBuilder(str);
//        String str2=builder3.toString();
    }
}
